<template>
  <div>
    <div class="shangpin">
      <van-icon name="arrow-left" @click="$router.push('/home')" />
      <span>快递单</span>
    </div>
    <!-- 搜索框 -->
    <van-search
      v-model="value"
      show-action
      shape="round"
      placeholder="快递单号"
      @search="onSearch"
    >
      <template #action>
        <div class="fontsiz" @click="onSearch">搜索</div>
      </template>
    </van-search>
    <!-- 快递单body -->
    <div class="describe" v-for="item in records" :key="item.id">
      <div class="box1">
        <p class="p1">快递单号:{{ item.orderCode }}</p>
        <van-icon
          name="arrow"
          @click="
            item.star == 1
              ? jump2(item.id, item.orderCode)
              : jump(item.id, item.orderCode)
          "
        />
      </div>

      <div class="xaing">
        <dl>
          <dt>
            <img :src="img01" alt="" />
          </dt>
          <dd>
            <p>
              <span>下单时间</span>
              <i>{{ item.createTime }}</i>
            </p>
            <p>
              <span>收货人</span>
              <i>{{ item.consignee }}</i>
            </p>
            <p>
              <span>发货人</span>
              <i>{{ item.consignor }}</i>
            </p>
          </dd>
        </dl>
      </div>
      <van-button
        color="#ffcd33"
        round
        type="primary"
        @click="
          item.star == 1
            ? jump2(item.id, item.orderCode)
            : jump(item.id, item.orderCode)
        "
        >{{ item.star == 1 ? "查看评价" : "评价" }}</van-button
      >
    </div>
  </div>
</template>

<script>
import StarChildwei from "@/components/StarChildwei";
import StarChild from "@/components/StarChild";
import { GetStarList } from "@/request/api";
import { Toast } from "vant";
export default {
  components: {
    StarChildwei,
    StarChild
  },
  data() {
    return {
      value: "",
      img01: "https://img01.yzcdn.cn/vant/custom-empty-image.png",
      records: []
    };
  },
  methods: {
    jump(id, orderCode) {
      this.$router.push(`/starChildwei?id=${id}&orderCode=${orderCode}`);
    },
    jump2(id, orderCode) {
      this.$router.push(`/starChild?id=${id}&orderCode=${orderCode}`);
    },
    GetStarAllList(keyword = "", current = 1, size = 10) {
      GetStarList({
        keyword,
        current,
        size
      }).then(res => {
        // console.log(res);
        this.records = res.data.records;
        // console.log(this.records);
      });
    },
    onSearch() {
      this.GetStarAllList(this.value);
    }
  },
  created() {
    this.GetStarAllList();
  }
};
</script>
 
<style lang = "less" scoped>
.shangpin {
  background-color: #003399;
  color: #fff;
  padding: 0.166667rem 0.066667rem;
  text-align: center;
  span {
    vertical-align: 0.03rem;
  }
  .van-icon {
    float: left;
    font-size: 0.186667rem;
  }
}
.fontsiz {
  color: #00297c;
}
.describe {
  background-color: #fff;
  margin-top: 0.133333rem;
  box-sizing: border-box;
  .p1 {
    line-height: 0.32rem;
    padding: 0.066667rem;
    margin: 0;
  }
  .van-icon {
    margin: 0.15667rem;
  }
}
.xaing {
  border-bottom: 1px solid #eee;
  border-top: 1px solid #eee;
  dl {
    display: flex;
    dt {
      width: 20%;
      padding: 0 0.066667rem;
      box-sizing: border-box;
      img {
        width: 100%;
      }
    }
    dd {
      margin: 0.066667rem;
      p {
        margin: 0.036667rem;
        i {
          font-weight: 600;
          margin-left: 0.126667rem;
        }
      }
      .p2 {
        font-weight: 600;
      }
    }
  }
}
.van-button {
  width: 1.066667rem;
  margin: 0.106667rem;
  margin-left: 2.8rem;
}
.box1 {
  display: flex;
  justify-content: space-between;
}
</style>